package com.the;

import java.util.*;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<String> list = new LinkedList<>();
        Collections.addAll(list,"小明","王二","张三","小李");
        list.forEach(System.out::println);
        //打乱顺序
        Collections.shuffle(list);
        list.forEach(System.out::println);
    }

    public static void test01(){
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        //倒序
        Collections.sort(list);
        list.forEach(System.out::println);
        Collections.sort(list, (o1, o2) -> {
            //实现倒序
            return o2  - o1;
        });
        list.forEach(System.out::println);

        List<Student> list01 = new ArrayList<>();
        list01.add(new Student("小明",20));
        list01.add(new Student("小李",23));
        list01.add(new Student("小红",21));
        list01.add(new Student("小王",22));
        Collections.sort(list01);
        list01.forEach(System.out::println);

        List<Integer> synchronizedList = Collections.synchronizedList(list);
    }
}
